package financial.sharing.center.payable.model.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import financial.sharing.center.common.base.BaseEntity;
import financial.sharing.center.common.enums.AccruedOperationStageEnum;
import financial.sharing.center.common.enums.EnableStatusEnum;
import financial.sharing.center.common.utils.BigDecimalUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @ClassName PayableAccrued
 * @Description TODO
 * @Author guoyuhang
 * @ @csdn https://blog.csdn.net/qq_40788718
 * @Date 2021/4/15
 * @Version 1.0
 */
@Data
@AllArgsConstructor
@ToString
@Entity
public class PayableAccrued extends BaseEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    /**合同id*/
    private Integer contractId;
    /**预估金额*/
    private BigDecimal settlementAmount;
    /**已勾稽金额*/
    private BigDecimal totalFeeAmount;
    /**计提操作阶段*/
    private Integer accruedOperationStageValue;
    @Transient
    private String accruedOperationStageName;
    /***/
    @Transient Integer billNumber;
    /**创建时间*/
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date createTime;
    /**备注*/
    private String note;
    /**是否弃用 0:无 1:正常 2:弃用*/
    private Integer enableStatusValue;

    public PayableAccrued(BigDecimal settlementAmount){
        this.settlementAmount = settlementAmount;
        this.totalFeeAmount = BigDecimalUtil.ZERO;
        this.createTime = new Date();
        this.accruedOperationStageValue = AccruedOperationStageEnum.已创建.getValue();
        this.enableStatusValue = EnableStatusEnum.正常.getValue();
    }

    public PayableAccrued() {

    }
}
